<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>轮询接口</title>
</head>
<body>
    

    <script>
    
        let a1 = {
            name: 'w'
        }

        let a2 = {
            name: 'a'
        }

        let a3 = {
            name: 'n'
        }

        let a4 = {
            name: 'g'
        }

        function asyFunc (data) {
            return new Promise((resolve,reject)=>{
                setTimeout(() => {
                    if(data){
                        resolve(data) 
                    }
                }, 1000);
            })
        }

        /* async function doit () {
            let p1 = await asyFunc(a1.name);
            let p2 = await asyFunc(a2.name);
            let p3 = await asyFunc(a3.name);
            let p4 = await asyFunc(a4.name);
            console.log(p1);
            console.log(p2);
            console.log(p3);
            console.log(p4);
        }

        doit(); */
        
        /* p.then(res=>{
            console.log(res);
            return asyFunc(a2.name);
        }).then(res=>{
            console.log(res);
            return asyFunc(a3.name);
        }).then(res=>{
            console.log(res);
            return asyFunc(a4.name);
        }).then(res=>{
            console.log(res);
        }) */
    
    </script>

</body>
</html>